<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_LOCALES_COLLECTION_KEY" scope="page" />
<atleap:constants className="org.apache.struts.Globals" var="LOCALE_KEY" scope="page" />
<atleap:content identifier="information" ignore="true" uri="/news/callCreateItemBody"/>
<c:set var="dontNeedCheckBoxes" value="${newsItemForm.localesMode != 'selected'}" />
<atleap:form action="news/updateItem" method="POST" validateOnSubmit="false">
    <atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
        <c:choose>
            <c:when test="${newsItemForm.localesMode == 'current'}">
                <c:choose>
                    <c:when test="${contentLocale.identifier == sessionScope[pageScope.LOCALE_KEY].language}">
                        <div class="languageField">
                            <atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
                            <c:if test="${empty languageTitle}">
                                <c:set var="languageTitle" value="${contentLocale.identifier}" />
                            </c:if>
                            <atleap:message key="news.form.language" />:&nbsp;${languageTitle}
                        </div>
                        <atleap:base var="baseHref" />
                        <atleap:contentEditor id="body(${contentLocale.identifier})" basePath="${ctxPath}/FCKeditor/"
                                width="100%" height="400px" defaultLanguage="${sessionScope[pageScope.LOCALE_KEY].language}"
                                baseHref="${baseHref}" editorAreaLanguage="${contentLocale.identifier}">
                            ${newsItemForm.bodyMap[contentLocale.identifier]}
                        </atleap:contentEditor>
                    </c:when>
                    <c:otherwise>
                        <html:hidden property="body(${contentLocale.identifier})" />
                    </c:otherwise>
                </c:choose>
            </c:when>
            <c:when test="${newsItemForm.localesMode == 'all'}">
                <div class="languageField">
                    <atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
                    <c:if test="${empty languageTitle}">
                        <c:set var="languageTitle" value="${contentLocale.identifier}" />
                    </c:if>
                    <atleap:message key="news.form.language" />:&nbsp;${languageTitle}
                </div>
                <atleap:base var="baseHref" />
                <atleap:contentEditor id="body(${contentLocale.identifier})" basePath="${ctxPath}/FCKeditor/"
                        width="100%" height="400px" defaultLanguage="${sessionScope[pageScope.LOCALE_KEY].language}" baseHref="${baseHref}"
                        editorAreaLanguage="${contentLocale.identifier}">
                    ${newsItemForm.bodyMap[contentLocale.identifier]}
                </atleap:contentEditor>
            </c:when>
            <c:when test="${newsItemForm.localesMode == 'selected'}">
                <c:choose>
                    <c:when test="${newsItemForm.bodyCheckedBoxes[contentLocale.identifier] != null}">
                        <div class="languageField">
                            <atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
                            <c:if test="${empty languageTitle}">
                                <c:set var="languageTitle" value="${contentLocale.identifier}" />
                            </c:if>
                            <atleap:message key="news.form.language" />:&nbsp;${languageTitle}
                        </div>
                        <atleap:base var="baseHref" />
                        <atleap:contentEditor id="body(${contentLocale.identifier})" basePath="${ctxPath}/FCKeditor/"
                                width="100%" height="400px" defaultLanguage="${sessionScope[pageScope.LOCALE_KEY].language}"
                                baseHref="${baseHref}" editorAreaLanguage="${contentLocale.identifier}">
                            ${newsItemForm.bodyMap[contentLocale.identifier]}
                        </atleap:contentEditor>
                    </c:when>
                    <c:otherwise>
                        <html:hidden property="body(${contentLocale.identifier})" />
                    </c:otherwise>
                </c:choose>
            </c:when>
        </c:choose>
        <html:hidden property="title(${contentLocale.identifier})" />
        <html:hidden property="annotation(${contentLocale.identifier})" />
    </atleap:iterator>
    <atleap:iterator items="${newsItemForm.annotationCheckedBoxes}" var="entry">
        <html:hidden property="annotationCheckedBox(${entry.key})" value="${entry.value}" />
    </atleap:iterator>
    <atleap:iterator items="${newsItemForm.bodyCheckedBoxes}" var="entry">
        <html:hidden property="bodyCheckedBox(${entry.key})" value="${entry.value}" />
    </atleap:iterator>

    <html:hidden property="id" />
    <html:hidden property="uri" />
    <html:hidden property="version" />
    <html:hidden property="active" />
    <html:hidden property="publicationDate" />
    <html:hidden property="expirationDate" />
    <html:hidden property="localesMode" />
    <atleap:cancel styleClass="button" type="back"><atleap:message key="core.commons.buttons.back" /></atleap:cancel>
    <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.update" /></atleap:submit>
    <atleap:cancel styleClass="button"><atleap:message key="core.commons.buttons.cancel" /></atleap:cancel>
</atleap:form>
